home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_2
/
external
< prev
next >
Wrap
Internet Message Format
|
1995-03-31
|
5KB
From HP-48@VM1.NoDak.EDU Sun Sep 9 19:29:58 1990
Received: from vm1.NoDak.edu by en.ecn.purdue.edu (5.61/1.27jrs)
id AA08517; Sun, 9 Sep 90 19:29:51 -0500
Message-Id: <9009100029.AA08517@en.ecn.purdue.edu>
Received: from NDSUVM1.BITNET by VM1.NoDak.EDU (IBM VM SMTP R1.2.1MX) with BSMTP id 9042; Sun, 09 Sep 90 19:28:53 CDT
Received: from NDSUVM1.BITNET by NDSUVM1.BITNET (Mailer R2.07) with BSMTP id
9035; Sun, 09 Sep 90 19:28:51 CDT
Date: Sun, 9 Sep 90 19:21:00 CST
Reply-To: HP-48 - HP-48sx Hand Held System <HP-48@VM1.NoDak.EDU>
Sender: HP-48 - HP-48sx Hand Held System <HP-48@VM1.NoDak.EDU>
From: TNAN0%ISUVAX.BITNET@VM1.NoDak.EDU
Subject: Re: Case and Programs
To: Multiple recipients of list HP-48 <HP-48@NDSUVM1>
Status: OR
Hello to Jason and the others:
Jason asked a question concerning EXTERNALs... I would like to take the time
to explain...
The representation inside the HP for ANY object looks like this:
[5 nibble address] <5 nibble length> <data>
The first five nibbles contain the address of the handling routine inside the
HP-48sx. For example, a string generates the address: 02A2Ch This is the
address of the string handler routine. (if you use the scanner: ON-D <- the
address will appear backward: C2A20h) If the handler expects more info
(like the string handler does), it is followed by a 5 nibble length. This
length always includes whatever data exists plus the 5 nibbles used for the
length field itself (eg., a 4 character string generates a length of 13.
4 bytes * 2 nibbles + 5 nibbles = 13). Then the data follows.
Functions and Commands (like SIN or NEXT) generate only the 5 nibble handler
address. This is because they require no extra data.
Now, what is an EXTERNAL??? Well, when the 48sx looks up the address in a
table (to find out what the real meaning behind 02A2Ch is...) it may find
an entry (such as SIN or whatever)... But if it does not, it assumes that
the program is just making a machine language jump to an EXTERNAL routine
and so it simply prints EXTERNAL... Obviously, you can't edit these
EXTERNALS because there is no single number that EXTERNAL translates to.
It simply means "a function that has no name". In a similar manner,
you can generate CODE onjects... These have the same structure as a string
but are actually a form of inline machine language. These have the
address 02DCCh, a 5 nibble length, and then a series of machine language
commands. These will show up as "Code" in a program, but when EVALuated
will execute the machine language inside... Again, you can't edit these
(probably because HP doesn't want you messing with things that could hurt
your memory).
A quick course in externals and code... PROCEED AT YOUR OWN RISK!
Try this... with nothing in your calculator (clear memory, no libraries,
no memory cards, NOTHING!), generate a string like this: "ABC"
Store this in a variable called 'WOW'. Now, enter the scanner. (For
those of you that don't know, the scanner is a built-in way to view and edit
memory directly, so BE CAREFUL!). To enter the scanner, hold down the ON key
and press D. You should get two vertical lines, now press the left arrow
(delete key), you should get something similar to this:
705D9:1B8DA178E5A111B6
705D9 is the address at which your version-printing routine is stored. To
execute the program at this address, hit EVAL. You should see:
Version HP48-D
Copyright HP 1989
You may get a different version letter (the latest is D)... Neat huh? You
can do this several times (since it returns you to the scanner)...
Now, let's take a look at that string we entered! Press: (and be careful)
ENTER / (that's divide)
The address should now be 00000. Now press '-' (minus) many times until the
address reads FFFEB. The display should look like this:
FFFEB:C2A20B0000142434
Ok, WOW! look... C2A20... that is the address of the string handler (remember?)
B0000 is the length, in decimal that's 11... (3 bytes * 2 nibbles + 5)
the "142434" is "ABC". "A" is 41 hex (stored backwards, it's "14").
Likewise, B is 42h and C is 43h... Neat, huh??? ok, make sure that your
display starts with C2A20 (after the address and the colon)... Now, CAREFULLY
type (no need for alpha or shift keys) CCD20. if you make a mistake, press
'-' (minus) until you get to your mistake and change it. Ok, now get back to
the calculator mode... Hold down ON and press C. Now, CAREFULLY press:
VAR BLUE-SHIFT WOW
Look! A code object on the stack! (If you made a mistake typing the number
CCD20, it will show up as an EXTERNAL... try it if you want...)
Do NOT evaluate this object (or just press the WOW key) or your calculator
will lock up (you COULD also lose memory... but memory should be empty
before you try this anyway)... When you are done playing, carefull purge
WOW ('WOW' PURGE) before you put things back into your calculator...
I would have provided a better example, but I am typing this directly
into MAIL and so I do not have an editor to assist me... If anyone is
interested in a Machine Language "lesson", please show some interest and
I will be happy to provide you with a lesson in writing a useful M/L program.
If anything in this message is incorrect, please forgive me. I have
not had time to go over it and make sure that it is not misleading...
---Xeno (Gary Snethen)
tnan0@isuvax
tnan0@ccvax.iastate.edu